using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;

namespace SqlTools.SchemaReader
{
	public class Parameter : ColumnBase
	{
		private bool _isOutput = false;

		public Parameter() : this("", 0) { }

		public Parameter(string name, int id)
			: base(name, id)
		{

		}

		public bool IsOutput
		{
			get { return _isOutput; }
			internal set { _isOutput = value; }
		}

		public override DbObjectType Type
		{
			get { return DbObjectType.Parameter; }
		}

		public override XmlElement CreateXmlElement(XmlDocument doc, XmlNode parent)
		{
			XmlElement el = base.CreateXmlElement(doc, parent);

			el.Attributes.Append(doc.CreateAttribute("isoutput")).Value = _isOutput.ToString();

			return el;
		}

		public override void LoadXml(XmlElement el, Database db)
		{
			base.LoadXml(el, db);

			string isoutput = el.GetAttribute("isoutput");

			if ( !bool.TryParse(isoutput, out _isOutput) )
				_isOutput = false;
		}
	}
}
